import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-06-29
 * Time: 15:26
 */
public class Deom3 {
    public static void main(String[] args) throws IOException {
        File file = new File("./text1.txt");
        //OutputStream outputStream  = new FileOutputStream(file);
        //版本1：
        /*outputStream.write(97);
        outputStream.write(98);
        outputStream.write(99);
        outputStream.write(100);*/
        //版本2：
        /*byte[] bytes = new byte[1024];
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = 1;
        }
        outputStream.write(bytes);*/
        //版本3：
        /*byte[] bytes = new byte[1024];
        for (int i = 0; i < bytes.length; i++) {
            bytes[i] = 1;
        }
        outputStream.write(bytes,0,10);*/
        try(OutputStream outputStream  = new FileOutputStream(file,true)) {
            byte[] bytes = new byte[1024];
            for (int i = 0; i < bytes.length; i++) {
                bytes[i] = 1;
            }
            outputStream.write(bytes,10,20);
        }
    }
}
